package entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@NamedNativeQueries({	
	@NamedNativeQuery(name="getSubCategoriaDespesa", query = "select * from subcategoria_despesa "
														, resultClass = SubCategoriaDespesaENT.class),
	@NamedNativeQuery(name="getFromCategoria", query = "select * from subcategoria_despesa "+
													   "where id_categoria = :id_categoria"
									   					, resultClass = SubCategoriaDespesaENT.class),
	@NamedNativeQuery(name="getSubcategoriaId", query = "select * from subcategoria_despesa "+
													    "where id = :id"
									   					, resultClass = SubCategoriaDespesaENT.class)								   					
})


@Entity
@Table(name="subcategoria_despesa")
public class SubCategoriaDespesaENT  implements Serializable{
/*------------------------------------------------------------------------------------*/	
	private static final long serialVersionUID = -808613820685994431L;
	@Id
	@GeneratedValue
	private int id;
	
	
	@ManyToOne
	@JoinColumn(name="id_usuario",nullable = false)
	private UsuarioENT usuario;	
	
	@ManyToOne
	@JoinColumn(name="id_categoria",nullable = false)
	private CategoriaDespesaENT idCategoria;
	
	@Column(name="nome",nullable = false)
	private String nome;
	
	@Column(name="data_alteracao",nullable = false)
	@Temporal(TemporalType.TIMESTAMP)		
	private Date dtAlteracao;
/*------------------------------------------------------------------------------------*/
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public UsuarioENT getUsuario() {
		return usuario;
	}

	public void setUsuario(UsuarioENT usuario) {
		this.usuario = usuario;
	}

	public CategoriaDespesaENT getIdCategoria() {
		return idCategoria;
	}

	public void setIdCategoria(CategoriaDespesaENT idCategoria) {
		this.idCategoria = idCategoria;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public Date getDtAlteracao() {
		return dtAlteracao;
	}

	public void setDtAlteracao(Date dtAlteracao) {
		this.dtAlteracao = dtAlteracao;
	}

	public SubCategoriaDespesaENT() {
		super();
	}
	
}
